/**
 * Created by Administrator on 2016/7/2 0002.
 */
$(document).ready(function(){
    getAjaxRequest({hf_s_id:"WD11",hf_srv_id:"Zv_jset_any_ddc"}, function() {
        getWeeeklySpecials();//获取每周精选
    });
});
//获取每周精选
function getWeeeklySpecials(){
    var shop = MPJ.getShopData();
    var arr={
        hf_s_id:"WD11",
        hf_srv_id:"Pv_jpdt_get",
        hs_action_id:"submit",
        hs_srch_item_no: shop.Home.ManagersSpecials.replace(/,/g,' ')
    };
    getAjaxRequest(arr,function(result){
        var productArr=setProductList_index(result);
        $('.content.vertical-list ul').html(productArr[0]);
        $('.countDisplay em').html(parseInt($('.countDisplay em').html())+productArr[1]);
        lookDetail();
    });
}


function lookDetail(){
    //两列数据的列表点击
    $('.vertical-list li').each(function(){
        var $this=$(this);
        $this.on('tap','.imgBox',function(){
            var pdt_id=$this.data('id');
            var item_no=$this.data('item-no');
            var product_info={};
            product_info.pdt_id=pdt_id;
            product_info.item_no=item_no;
            sessionStorage.setItem('product_info',JSON.stringify(product_info));
            location.href=MPJ.base+"/pages/product/product-detail.jsp";
        })
        $this.on('tap','.addCar',function(){
            var pdt_id=$this.data('id');
            var item_no=$this.data('item-no');
            var arr={
                hf_s_id:"WD11",
                hf_srv_id:"Av_jcart",
                hs_action_id:"add_all_to_cart",
                hvs_add_pdt_id:pdt_id,
                hvs_add_qty:$this.find('.mui-numbox-input').val(),
            };
            getAjaxRequest(arr,function(result){
                if(result.bs_result==BS_RESULT.OK){
                    dialog('Message', 'Add to Shopping Cart', 1);
                    var $dialog = $('#dialog');
                    $dialog.show();
                    $dialog.find('.comfirmBtn').one('click', function() {
                        $dialog.hide();
                        $dialog.remove();
                        getCartSumCount();
                    })
                }

            });

        })
    })

}
